<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name = "viewport" content = "width = device-width, initial-scale = 1.0, maximum-scale = 1.0, user-scalable = 0" />
    <title>{{ isset($links->title) ? $links->title : "外链异常" }}</title>
    <style>
        body{
            margin: 0px;
            padding: 0px;
        }
        .full {
            width: 100%;
            float: left;
            text-align: center;
            height: auto;
        }
    </style>
    <link rel="shortcut icon" href="https://ttwls.oss-cn-beijing.aliyuncs.com/assets/images/admin/favicon.ico"/>
    <link rel="stylesheet" type="text/css" href="https://res.wx.qq.com/open/libs/weui/2.4.0/weui.min.css">
</head>
<body>
    <div class="full">
        <wx-open-launch-weapp id="launch-btn" username="{{ $username }}" path="{{ $path }}" style="float: left;width: 100%;height: 100%;text-align: center;display: flex;justify-content: center;">
            <template>
                <div style="width: 100%;margin: 0px auto;float: left;">
                @if(!empty($links))
                    @if(in_array($styles->style, [1,2]))
                    <div style="width: 100%;float: left;height: 40px;line-height: 40px;text-align: center;padding: 10px 0px;box-sizing: border-box;display: flex;justify-content: center;position: absolute;top: 0px;">
                        <img src="https://nilife.oss-cn-beijing.aliyuncs.com/miniapp/images/setting/safe.png" style="width: 16px;height: 16px;margin-right: 3px;margin-top: 1px;">
                        <p style="width: auto;height: 20px;line-height: 20px;font-size: 12px;color: #999999;margin: 0px;">本链接经过<font style="font-weight: 500;color: #333333;">SSL安全加密</font>,请放心点击!</p>
                    </div>
                    @endif
                    @if(in_array($styles->style, [1,2,5]))
                        @if($styles->style == 2)
                        <div style="width: 100%;float: left;text-align: center;">
                            <img src="{{ $styles->logo }}" style="width: 80px;height: auto;margin: 160px auto 0px auto;">
                        </div>
                        @else
                        <div style="width: 100%;float: left;text-align: center;">
                            <img src="https://nilife.oss-cn-beijing.aliyuncs.com/wepage/20210421-180054-178.png" style="width: 80px;height: auto;margin: 160px auto 0px auto;">
                        </div>
                        @endif
                        <p style="width: 100%;float: left;line-height: 30px;text-align: center;margin: 10px 0px 20px 0px;padding: 0px 15px;box-sizing: border-box;color: #666666;font-size: 15px;float: left;">请点击下方按钮跳转到微信小程序</p>
                        <div style=" width: 100%;height: 50px;line-height: 50px;font-weight: 300;float: left;text-align: center;">
                            <div style="display: block;width: 280px;height: 50px;line-height: 50px;font-weight: 300;font-size: 15px;background-color: {{ $styles->button_background_color }};color: {{ $styles->button_text_color }};margin: 0px auto;position: relative;border-radius: {{ $styles->button_border == 1 ? '3px':'50px' }}">
                                {{ $styles->botton_text }}
                            </div>
                        </div>                  
                    @else
                        <img src="{{ $styles->logo }}" style="width: 100%;height: auto;float: left;">
                    @endif
                @else
                        <img style="width: 80px;height: 80px;margin: 50px auto 10px auto;" src="/images/error.png">
                        <p style="width: 100%;float: left;line-height: 30px;text-align: center;padding: 0px 15px;box-sizing: border-box;color: #666666;font-size: 15px;">{{ $msg }}</p>
                @endif
                </div>
            </template>
        </wx-open-launch-weapp>
    </div>

    <script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
    <script src="https://nilife.oss-cn-beijing.aliyuncs.com/miniapp/images/setting/jquery-3.5.1-min.js"></script>
    <script src="https://wailiancn.oss-cn-beijing.aliyuncs.com/assets/js/v2/wailian-2.0.js"></script>
<script>
    
    $(function () {
        wx.config({
            debug: false,
            appId: '{{ $appid }}', // 必填，公众号的唯一标识
            timestamp: '{{ $timestamp }}', // 必填，生成签名的时间戳
            nonceStr: '{{ $nonceStr }}', // 必填，生成签名的随机串
            signature: '{{ $signature }}',// 必填，签名
            jsApiList: ["chooseImage"],//必须要不调用小程序标签渲染不出来
            openTagList: ['wx-open-launch-weapp']//必须必须要不调用小程序标签渲染不出来
        });
        wx.ready(function () {
            console.log("ready");
            $("#launch-btn").click();
        });

        wx.error(function (res) {
            // config信息验证后会执行ready方法，所有接口调用都必须在config接口获得结果之后，config是一个客户端的异步操作，所以如果需要在页面加载时就调用相关接口，则须把相关接口放在ready函数中调用来确保正确执行。对于用户触发时才调用的接口，则可以直接调用，不需要放在ready函数中
            // console.log("res", res);
            // alert(JSON.stringify(res));
            // alert(1);
        });        

        var btn = document.getElementById('launch-btn');
        btn.addEventListener('launch', function (e) {
            console.log('success');
        });
        btn.addEventListener('error', function (e) {
            console.log('fail', e.detail);
        });
        // window.location.href = "{{ $links->urlscheme }}";
        // linksIpStatistics("{{ $links->links_id }}","2");
    });


</script>
</body>
</html>



